home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------
- *
- * You may freely copy, distribute, and reuse the code in this example.
- * SHL Systemhouse disclaims any warranty of any kind, expressed or
- * implied, as to its fitness for any particular use.
- *
- *
- * *
- *
- *
- * Conforms To: None
- *
- * Declared In: EOFDelegateAdaptorCategory.h
- *
- * Courtesy of SHL Object Technology Center
- *------------------------------------------------------------------------*/
-
-
- #import "EOFDelegateAdaptorCategory.h"
- #import "Evaluator.h"
-
- @implementation EOFDelegateAdaptorCategory
- /*--------------------------------------------------------------------------
- * EOAdaptor Delegate Methods
- *------------------------------------------------------------------------*/
- - (BOOL)adaptor:(EOAdaptor *)adaptor willReportError:(NSString *)error
- {
- // An adaptor sends this message to its delegate when an error has
- // occurred. If the delegate returns NO, the adaptor doesn't open an
- // alert panel (or log the error to the console if it isn't in an
- // application).
-
- BOOL result = YES;
-
- [[[NXApp mainWindow] delegate] announce:adaptor
- selector:_cmd
- with:[NSArray arrayWithObject:error]];
-
-
- return result;
- }
-
-
- /*--------------------------------------------------------------------------
- * EOAdaptorContext Delegate Methods
- *
- * EOAdaptorContext sends messages to its delegate for any transaction
- * begin, commit, or rollback. The delegate can use these methods to
- * preempt these operations, modify their results, or simply track activity.
- *
- * EODelegateResponse is used to indicate the result a delegate demands
- * on notification that a particular action will be taken. If a delegate
- * returns EODelegateRejects, the sender of the delegation message must
- * abort the current operation and return a failure result. If the
- * delegate returns EODelegateApproves, the sender may continue the
- * operation and return whatever result is appropriate. If the delegate
- * returns EODelegateOverrides, the sender must do nothing, but return a
- * success result. When a delegate overrides an operation it's
- * responsible for seeing that the result of that operation is performed
- * successfully.
- *
- * typedef enum {
- * EODelegateRejects, EODelegateApproves, EODelegateOverrides
- * } EODelegateResponse;
- *
- *------------------------------------------------------------------------*/
-
- - (EODelegateResponse)adaptorContextWillBegin:context
- {
- // Invoked from -beginTransaction to tell the delegate that
- // a transaction is being started.
-
- int result = EODelegateApproves;
-
- [[[NXApp mainWindow] delegate] announce:context selector:_cmd];
-
-
- return result;
- }
-
-
- - (void)adaptorContextDidBegin:context
- {
- // Invoked from -beginTransaction or -transactionDidBegin to tell the
- // delegate that a transaction has begun. The delegate may take whatever
- // action it needs based on this information.
-
- [[[NXApp mainWindow] delegate] announce:context selector:_cmd];
- }
-
-
- - (EODelegateResponse)adaptorContextWillCommit:context
- {
- // Invoked from -commitTransaction to tell the delegate that
- // a transaction is being committed.
-
- int result = EODelegateApproves;
-
- [[[NXApp mainWindow] delegate] announce:context selector:_cmd];
-
- return result;
- }
-
-
- - (void)adaptorContextDidCommit:context
- {
- // Invoked from -commitTransaction or -transactionDidCommit to tell the
- // delegate that a transaction has been committed. The delegate may take
- // whatever action it needs based on this information.
-
- [[[NXApp mainWindow] delegate] announce:context selector:_cmd];
- }
-
-
- - (EODelegateResponse)adaptorContextWillRollback:context
- {
- // Invoked from -rollbackTransaction to tell the delegate that
- // a transaction is being started.
-
- int result = EODelegateApproves;
-
- [[[NXApp mainWindow] delegate] announce:context selector:_cmd];
-
- return result;
- }
-
-
- - (void)adaptorContextDidRollback:context
- {
- // Invoked from -rollbackTransaction or -transactionDidRollback to tell
- // the delegate that a transaction has been rolled back. The delegate may
- // take whatever action it needs based on this information.
-
- [[[NXApp mainWindow] delegate] announce:context selector:_cmd];
- }
-
-
- /*--------------------------------------------------------------------------
- * EOAdaptorChannel Delegate Methods
- *
- * EOAdaptorChannel sends messages to its delegate for nearly every
- * operation that would affect data in the database server. The delegate can
- * use these methods to preempt these operations, modify their results,
- * or simply track activity.
- *
- * IMPORTANT: read the comments for the EODelegateResponse type in
- * EOAdaptorContext.h for information on how the adaptor channel interprets
- * delegate responses.
- *
- *------------------------------------------------------------------------*/
-
-
- - (void)adaptorChannelDidChangeResultSet:channel
- {
- // Invoked from -fetchAttributes:withZone: to tell the delegate that
- // fetching will start for the next result set, when a select operation
- // resulted in multiple result sets. This method is invoked just after a
- // -fetchAttributes:withZone: returns nil when there are still result sets
- // left to fetch.
-
- [[[NXApp mainWindow] delegate] announce:channel selector:_cmd];
- }
-
-
- - (void)adaptorChannelDidFinishFetching:channel
- {
- // Invoked from -fetchAttributes:withZone: to tell the delegate that
- // fetching is finished for the current select operation. This method is
- // invoked when a fetch ends in -fetchAttributes:withZone: because there
- // are no more result sets.
-
- [[[NXApp mainWindow] delegate] announce:channel selector:_cmd];
- }
-
-
- - (EODelegateResponse)adaptorChannel:channel
- willEvaluateExpression:(NSMutableString *)expression
- {
- // Invoked from -evaluateExpression: to tell the delegate that an
- // expression is about to be sent to the database server. The delegate
- // may modify expression to affect the result.
-
- int result = EODelegateApproves;
-
- [[[NXApp mainWindow] delegate] announce:channel
- selector:_cmd
- with:[NSArray arrayWithObject:expression]];
-
- return result;
- }
-
-
- - (void)adaptorChannel:channel
- didEvaluateExpression:(NSString *)expression
- {
- // Invoked from -evaluateExpression: to tell the delegate that a query
- // language expression has been evaluated by the database server. The
- // delegate may take whatever action it needs based on this information.
-
- [[[NXApp mainWindow] delegate] announce:channel
- selector:_cmd
- with:[NSArray arrayWithObject:expression]];
- }
-
-
- @end
-
-